<include file="Public/header" title="编辑" />
<div id="page-wrapper">
    <form method="post" action="{:U('Slide/update?id=')}{$category.id}"  enctype="multipart/form-data">
        <div class="form-group">
            <label for="post-title">标题</label>
            <input type="text" name="title" class="form-control" value="{$post.title}" id="post-title" placeholder="输入标题">
        </div>
        <div class="form-group">
            <label for="post-title">Url</label>
            <input type="text" name="link" class="form-control" value="{$post.link}" id="post-link" placeholder="输入链接地址">
        </div>
      <style>
      div.imglist{ margin:0 auto; width:100%; overflow:hidden; z-index:9999999;} 
      div.imglist div{ float:left; margin:4px;padding:2px; width:160px; background-color:#dbdbdb;list-style-type: none; position:relative;} 
      div.imglist div img{ display:block; width:156px; height:156px;} 
      div.imglist div span{ position:absolute;top:2px;right:2px; display:block; width:30px; height:30px; line-height:30px; background:url("Public/images/cha.png") no-repeat;} 
      </style>
        <div class="form-group">
            <label for="post-title">图片</label>
             <input type="file" name="pic[]" class="form-control" id="post-pic" >
        </div>
        <div class="form-group">
		<div class="imglist"> 
        <?php
        $items=$post['imgurl'];  
        $arr = explode("|",$items);
        for($i=0;$i<count($arr)-1;$i++){
        echo "<div class='del_1' data-url='$arr[$i]'><img src='Public/$arr[$i]'  alt=''/><span></span></div>";
        }
        ?>
		</div>
        </div>
        <div class="form-group"  style="display:none;">
            <label for="post-cate">分类</label>
            <select name="cate_id" id="post-cate" class="form-control">
                <foreach name="category" item="v">
                    <option value="{$v.id}" <?php if($post['cate_id'] == $v['id']) {echo 'selected="selected"' ;}?>>{$v.html} {$v.title}</option>
                </foreach>
            </select>
        </div>
        <div class="form-group">
            <label for="post-content">内容</label>
            <script id="post-content" name="content" type="text/plain">{$post.content|htmlspecialchars_decode}</script>
        </div>
        <input type="hidden" name="id" value="{$post.id}">
        <button type="submit" class="btn btn-default">提交</button>
    </form>
</div>
<!-- 配置文件 -->
<script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
    var ue = UE.getEditor('post-content',{
        toolbars: [
            ['fullscreen', 'source', 'undo', 'redo','bold', 'italic', 'underline','fontborder', 'strikethrough', '|','simpleupload', 'insertimage','attachment','emotion','link','unlink', '|', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote','searchreplace', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc'],
            ['inserttable','insertrow', 'insertcol','mergeright', 'mergedown','deleterow', 'deletecol','splittorows','splittocols', 'splittocells','deletecaption','inserttitle', 'mergecells', 'deletetable','insertparagraphbeforetable', 'paragraph','fontsize','fontfamily']
        ],
        initialFrameHeight:300,
        zIndex:100
    });
</script>
<include file="Public/footer" />
<script type="text/javascript">
$(function(){
    $(".del_1").click(function(){
         var delurl = $(this).data("url");
		 $(this).remove();
         var id = GetQueryString("id");
         $.ajax({
            type:"POST",
            url:"{:U('Admin/Slide/delarr_1')}",
            data:{
                id:id,
                url:delurl
            },
            success:function(data){
                
            },
            error:function(){
                alert("error");
            }
         })
    });
});


function GetQueryString(name){
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if(r!=null)return  unescape(r[2]); return null;
}
</script>